/**
 * @Author: 魏巍
 * @Date:   2018-09-24T23:32:44+08:00
 * @Email:  524314430@qq.com
 * @Filename: index.js
 * @Last modified by:   魏巍
 * @Last modified time: 2018-09-26T01:54:10+08:00
 * @Copyright: free
 */

const router = require('koa-router')()

router.get('/', async (ctx, next) => {
  ctx.rediret('/index')
})

router.get('/index', async (ctx, next) => {
  await ctx.render('index', {
    title: 'Hello Koa 2!'
  })
})

router.get('/string', async (ctx, next) => {
  ctx.body = 'koa2 string'
})

router.get('/json', async (ctx, next) => {
  ctx.body = {
    title: 'koa2 json'
  }
})

module.exports = router
